################################################################
# Fulguro
# Copyright (C) 2004 Christophe Clienti
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
################################################################

include ../Makefile.include

MODULES		= arith core datatools histogram image linear matrix measure morpho rtview rtcapture
OBJS 		= $(shell \find . -name *.o)
SRCS            = $(shell \find . -name *.h)

.PHONY: $(MODULES)

all : ../lib/$(LIBNAME).so ../lib/$(LIBNAME).a header

install: ../lib/$(LIBNAME).so ../lib/$(LIBNAME).a header
	mkdir -p $(INSTALL_DIR_H)
	mkdir -p $(INSTALL_DIR_LIB)
	cp -f $(SRCS) $(INSTALL_DIR_H)
	cp ../lib/$(LIBNAME).a $(INSTALL_DIR_LIB)
	cp ../lib/$(LIBNAME).so $(INSTALL_DIR_LIB)

header:
	mkdir -p ../include
	cp -f $(SRCS) ../include

../lib/$(LIBNAME).so: objects
	mkdir -p ../lib
	$(CC) $(LDFLAGS) $(LIBDIR) -shared -o ../lib/$(LIBNAME).so $(OBJS)

../lib/$(LIBNAME).a: objects
	$(AR) rcs ../lib/$(LIBNAME).a  $(OBJS)
	$(RANLIB) ../lib/$(LIBNAME).a

objects: $(MODULES)

$(MODULES):
	cd $@; $(MAKE) all

clean :
	for dir in $(MODULES); do \
		(cd $$dir; ${MAKE} clean); \
	done
	@rm -rf *~
	@rm -rf ../lib/*.a
	@rm -rf ../lib/*.so
	@rm -rf ../include/*.h
	@rm -rf $(INSTALL_DIR_LIB)/$(LIBNAME).so
	@rm -rf $(INSTALL_DIR_LIB)/$(LIBNAME).a